'use strict';
let db = require('../model/db.js');
let date = require('date-and-time');


module.exports = (req,res)=>{
    let content = req.body.content;
    let isFinished = req.body.isFinished === 'true';
    let now = new Date();
    let strNow = date.format(now, 'YYYY/MM/DD HH:mm:ss');
    db.insert('list',{
        docs:{
            content : content,
            updateTime : strNow,
            isFinished : isFinished
        },
        callback:(err,result)=>{
            if(err){
                res.json(err);
                return;;
            }
            res.json(result);
        }
    });
}